<?php
	$ln=$_POST['lname'];
	$fn=$_POST['fname'];
	$em=$_POST['email'];
	$cm=$_POST['comment'];
	
	//include class for mail
    require_once('class.phpmailer.php');
    $mail = new PHPMailer(true);

    //telling the class to use SMTP
    $mail->IsSMTP();
	try {
            // SMTP server
            $mail->Host = "mail.hrcambodia.com";
            // enables SMTP debug information (for testing),  show debug : SMTPDebug  = 2,  Hide debug : SMTPDebug  = 1
            $mail->SMTPDebug = 1;
            // enable SMTP authentication
            $mail->SMTPAuth = true;
            // sets the SMTP server		
            $mail->Host = "mail.hrcambodia.com";
            // set the SMTP port for the MY OWN DOMAIN server
            $mail->Port = 25;
            // SMTP account username		
            $mail->Username = "support@hrcambodia.com";
            // SMTP account password
            $mail->Password = "t$=hI5M+CKqI";
			
            //$mail->AddReplyTo('support@hrcambodia.com', 'HRCambodia.com');
			//All comment will send to the below e-mail
            //$mail->AddAddress('cyudeth@gmail.com', 'HRCambodia.com');
			$mail->AddAddress('support@hrcambodia.com', 'HRCambodia.com');
			
            $email_address = filter_input(INPUT_GET, $_POST['email'], FILTER_VALIDATE_EMAIL);
            if (!$email_address) {
                $mail->SetFrom('support@hrcambodia.com', 'HRCambodia.com');
				//$mail->AddAddress('cyudeth@gmail.com', $fn." ".$ln);
				$mail->AddAddress("".$em."", 'HRCambodia');
				
                $mail->Subject = 'Customer support request';
                // optional - MsgHTML will create an alternate automatically
                $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
                $mail->MsgHTML("This is an auto-generated copy of support request that has been sent at HRCambodia.com website.<BR>Please allow a minimum of 24 hours for a reply below is the content of your support request:<BR><BR> First name: <B>".$fn."</B><BR>Last name: <B>".$ln."</B><BR>Comment: <B>".$cm."</B><BR><HR>HRCambodia.com Team<BR>Email: <B>info@hrcambodia.com</B><BR>Website: <B>www.hrcambodia.com</B></p>");
                $mail->Send();
                //echo "Your message have been send. Thank you...!";
				//echo('<script language="javascript">alert("Thank you for comments!");</script>');
				header("Location: ../support.php");
            } else {
                echo 'Email is invalid...';
                break;
            }
        } catch (phpmailerException $e) {
            //Pretty error messages from PHPMailer
            echo $e->errorMessage();
        } catch (Exception $e) {
            //Boring error messages from anything else!
            echo $e->getMessage();
        }
		
?>
